package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.*;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

/**
 * 产品信息查询
 * @author Administrator
 */
@RestController
@RequestMapping("userApi/goods")
@Api(description = "产品系列",tags="产品系列")
public class GoodsController extends BaseController {

    @PostMapping("/getCompanyInfo")
    @ApiOperation(value = "查询公司信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = false,paramClass = CompanyRequest.class)
    @Deprecated
    public ResultModel getCompanyInfo(@RequestAttribute CompanyRequest request){
        
        return userFegin.getCompanyInfo(request);
    }

    @PostMapping("/getCompanyInfo/V2")
    @ApiOperation(value = "查询公司信息")
    @ApiImplicitParams({
                    @ApiImplicitParam(name = "companyId", value = "公司ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = CompanyRequest.class)
    public ResultModel getCompanyInfoV2(@RequestAttribute CompanyRequest request){

        return userFegin.getCompanyInfo(request);
    }

    @PostMapping("/getGoodsType")
    @ApiOperation(value = "根据公司查询产品分类")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyId", value = "公司ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = GoodstypeRequest.class)
    public ResultModel getGoodsType(@RequestAttribute GoodstypeRequest request){
        
        return userFegin.getGoodsType(request);
    }

    @PostMapping("/getGoodsList")
    @ApiOperation(value = "根据产品分类查询产品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodstypeId", value = "产品分类ID", paramType = "Integer"),
    })
    @ApiController(isLogin = false,paramClass = GoodsRequest.class)
    @Deprecated
    public ResultModel getGoodsList(@RequestAttribute GoodsRequest request){
        
        return userFegin.getGoodsList(request);
    }

    @PostMapping("/getGoodsList/V2")
    @ApiOperation(value = "根据产品分类查询产品")
    @ApiImplicitParams({
                    @ApiImplicitParam(name = "goodstypeId", value = "产品分类ID", paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = GoodsRequest.class)
    public ResultModel getGoodsListV2(@RequestAttribute GoodsRequest request){

        return userFegin.getGoodsList(request);
    }

    @PostMapping("/getGoodSpec")
    @ApiOperation(value = "根据产品查询规格")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodsId", value = "产品ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = GoodSpecRequest.class)
    public ResultModel getGoodSpec(@RequestAttribute GoodSpecRequest request){
        
        return userFegin.getGoodSpec(request);
    }

    @PostMapping("/getGoodsInfo")
    @ApiOperation(value = "查询产品详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "goodsId", value = "产品ID", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = GoodsRequest.class)
    public ResultModel getGoodsInfo(@RequestAttribute GoodsRequest request) {
        
        return userFegin.getGoodsInfo(request);
    }

    @PostMapping("/goodsCard")
    @ApiOperation(value = "获取产品海报")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "specId", value = "商品类型id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = GoodSpecRequest.class)
    ResultModel goodsCard(@RequestAttribute GoodSpecRequest request){
        return userFegin.goodsCard(request);
    }

}
